package servlets;

import javax.servlet.*;
import java.io.IOException;

public class OtherServlet implements Servlet {

    private ServletConfig config;

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        this.config = servletConfig;
    }

    @Override
    public ServletConfig getServletConfig() {
        return config;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {

        ServletContext servletContext = config.getServletContext();

        //获取域属性的值
        String mobile = (String)servletContext.getAttribute("mobile");

        System.out.println("mobile = " + mobile);

        //重置域属性的值
        servletContext.setAttribute("mobile","111111111111");

        //删除域属性
        servletContext.removeAttribute("email");


    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
